using NExt.Serialization;

namespace NExt.Core.Validator
{
    public class NotNull : ValidatorScript
    {
        private const string FUNCTION_NAME = "NotNull";
        public static NotNull Instance = new NotNull();

        private NotNull(params string[] parameterNames)
            : base(FUNCTION_NAME, parameterNames)
        {
        }

        public static NotNull Create(string message, object nullValue)
        {
            string serializedMessage = JsonSerializer.Serialize(message);
            string serializedNullValue = JsonSerializer.Serialize(nullValue);
            string parameter = string.Format("{0},{1}", serializedMessage, serializedNullValue);
            NotNull notNull = new NotNull(parameter);
            return notNull;
        }

        public static NotNull Create(string message)
        {
            return Create(message, null);
        }

        public static NotNull Create(object nullValue)
        {
            return Create(null, nullValue);
        }

    }
}